import Worker from 'worker-loader!@/workers/message'
import store from '@/store'
import { getToken } from '@/utils/commonUtils/HLUtils'

export default function() {
  var worker = new Worker()
  if (!store.state.user.userInfo.userId) {
    return
  }
  worker.postMessage({
    token: getToken(),
    id: store.state.user.userInfo.userId
  })
  worker.onmessage = e => {
    store.dispatch('message/setList', e.data.list)
  }
}
